<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="template">
<body>
<th:block layout:fragment="content">

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>基本
                            <small>分类，查找</small>
                        </h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row m-b-sm m-t-sm">

                            <div class="col-md-2">
                                <div class="input-group">
                                    <select class="form-control input-sm formSearch" skey="companyId">
                                        <option th:each="ec:${actCenterCompanyMap}" th:value="${ec.id}" th:text="${ec.name}" selected></option>
                                    </select>
                                </div>
                            </div>

                            <div class="col-md-2">
                                <div class="input-group">
                                    <select class="form-control input-sm formSearch" skey="decodeMethod">
                                        <option value="" selected>编码方式</option>
                                        <option th:each="ec:${decodeMethodList}" th:value="${ec.key}" th:text="${ec.val}"></option>
                                    </select>
                                </div>
                            </div>

                            <!--
                            <div class="col-md-2">
                                <div class="input-group">
                                    <input class="input-sm form-control formSearch" type="text" placeholder="单据名称" skey="typeName"/>
                                </div>
                            </div>
                            -->

                            <div class="col-md-1">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button onclick="formReset();" class="btn btn-sm btn-primary" type="button"> 重置</button>
                                    </span>
                                </div>
                            </div>
                            <div class="col-md-1">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button onclick="tableQuery()" class="btn btn-sm btn-primary" type="button"> 搜索</button>
                                    </span>
                                </div>
                            </div>
                        </div>


                        <div class="row m-b-sm m-t-sm">
                            <div class="col-md-2">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <button onclick="addWin();" class="btn btn-sm btn-primary" type="button">新增</button>
                                    </span>
                                </div>
                            </div>

                        </div>

                        <div class="hr-line-dashed m-t-sm m-b-sm"></div>
                        <table id="searchTable" class="table table-striped table-bordered table-hove dataTables-example">
                            <thead>
                            <tr>
                                <th>Id</th>
                                <th>公司名称</th>
                                <th>单据名称</th>
                                <th>编码方式</th>
                                <th>前缀1</th>
                                <th>前缀1值</th>
                                <th>前缀2</th>
                                <th>前缀2值</th>
                                <th>前缀3</th>
                                <th>前缀3值</th>
                                <th>流水号长度</th>
                                <th>流水号起始</th>
                                <th>分隔符</th>
                                <th>备注</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>


    <!-- 编辑 -->
    <div class="modal inmodal" id="editWin" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title"></h4>
                </div>

                <div class="modal-body">
                    <input type="hidden" class="form-control formSubmit" skey="id">
                    <form class="form-horizontal m-t" id="msgform">

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">编码方式：</label>
                            <div class="col-sm-8">
                                <select class="form-control input-sm formSubmit" skey="decode_method">
                                    <option th:each="ec:${decodeMethodList}" th:value="${ec.key}" th:text="${ec.val}"></option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀1：</label>
                            <div class="col-sm-8">
                       <!--        <input type="text" class="form-control formSubmit" skey="prifix_first">  -->
                            	<select class="form-control input-sm formSubmit" skey="prifix_first">
                                    <option th:each="dc:${decodePrifixList}" th:value="${dc.key}" th:text="${dc.val}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀1的值：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="first_value">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀2：</label>
                            <div class="col-sm-8">
                         <!--       <input type="text" class="form-control formSubmit" skey="prifix_second">   --->
                         		<select class="form-control input-sm formSubmit" skey="prifix_second">
                                    <option th:each="dc:${decodePrifixList}" th:value="${dc.key}" th:text="${dc.val}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀2的值：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="second_value">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀3：</label>
                            <div class="col-sm-8">
                <!--                <input type="text" class="form-control formSubmit" skey="prifix_three">   --->
                				<select class="form-control input-sm formSubmit" skey="prifix_three">
                                    <option th:each="dc:${decodePrifixList}" th:value="${dc.key}" th:text="${dc.val}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">前缀3的值：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="three_value">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">流水号长度：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="serial_num">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">流水号起始值：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="serial_num_star">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">分隔符：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="separator">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label" style="text-align:center">备注：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control formSubmit" skey="remark">
                            </div>
                        </div>
                    </form>

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal" onclick="winClose('editWin');">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="" id="dataSubmit">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script th:inline="javascript">

        $(function () {
            /*<![CDATA[*/
            var decodeMethodMap = [[${decodeMethodMap}]];
            var decodePrifixMap = [[${decodePrifixMap}]];
            var actCenterCompanyMap = [[${actCenterCompanyMap}]];
            var typeName = [[${typeName}]];
            var typeId = [[${type_id}]];
            var actCenterCompany = [[${actCenterCompany}]];
            /*]]>*/
            $("#dataSubmit").bind('click', function(){
                winFormSubmit('/basic/bill/deocde/param/edit_execute?type_id=' + typeId + "&company_id=" + actCenterCompany.id);
            });

            var renderMap = {};

            renderMap["company_id"] = function (data, type, row, meta){
                return getObjAVal(actCenterCompanyMap, data-1, "name");
            };

            renderMap["decode_method"] = function (data, type, row, meta){
                return getObjAVal(decodeMethodMap, data);
            };

            renderMap["prifix_first"] = function (data, type, row, meta){
                return getObjAVal(decodePrifixMap, data);
            };

            renderMap["prifix_second"] = function (data, type, row, meta){
                return getObjAVal(decodePrifixMap, data);
            };

            renderMap["prifix_three"] = function (data, type, row, meta){
                return decodePrifixMap[data];
            };

            renderMap["type_id"] = function (data, type, row, meta){
                return typeName;
            };

            var cnames = ["id", "company_id", "type_id", "decode_method", "prifix_first", "first_value", "prifix_second", "second_value", "prifix_three", "three_value", "serial_num", "serial_num_star", "separator", "remark", "ctime"];
            tableInit('searchTable', tableInitColumnsFmt(cnames, renderMap, []), "/basic/bill/deocde/param/data?typeId=" + typeId, "/basic/bill/deocde/param/edit", "/basic/bill/deocde/param/del_execute", "editWin");
        });
    </script>

</th:block>


</body>
</html>
